package cn.gyouzhe.mapper;

import cn.gyouzhe.entity.Seller;
import org.apache.ibatis.annotations.*;

/**
 * 卖家mapper
 *
 * @author wangchuan
 * @datetime 2018/2/28 23:17
 */
@Mapper
public interface SellerMapper {
    /**
     * 根据卖家ID获取卖家信息
     * @param sellerId  卖家ID
     * @return 卖家信息
     */
    @Select("select id,seller_id,seller_name from g_seller where seller_id=#{sellerId}")
    @Results({
            @Result(property = "id", column = "id", id = true),
            @Result(property = "sellerId", column = "seller_id"),
            @Result(property = "shopName", column = "seller_name")
    })
    Seller selectSeller(@Param("sellerId") String sellerId);

    /**
     * 保存卖家信息
     * @param seller 卖家信息
     */
    @Insert("insert into g_seller(seller_id,seller_name) values(#{sellerId},#{shopName})")
    @Options(useGeneratedKeys = true)
    void saveSeller(Seller seller);

    /**
     * 更新卖家信息
     * @param seller 卖家信息
     */
    @Update("update g_seller set seller_name=#{shopName} where seller_id=#{seller_id}")
    void updateSeller(Seller seller);
}
